<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .div1 {
            background-color: #d7d7d7;
            width: 1280px;
            height: 400px;
            margin: auto;
            display: flex;
            /* 本来想让弹性盒中的弹性项(弹性盒的子元素)水平和垂直居中需要两行 */
            /* justify-content: center;
            align-items: center; */
        }

        .box1 {
            background-color: #e15d5d;
            width: 100px;
            height: 100px;
            border: 2px solid #563432;
            /* 在弹性项中加入margin: auto;就能做到水平和垂直居中   */
            margin: auto;
        }

        .div2 {
            margin: auto;
            margin-top: 10px;
            background-color: #d7d7d7;
            width: 1280px;
            height: 120px;
            display: flex;
            align-items: center;
        }

        .d2 {
            width: 100px;
            height: 100px;
            border: 2px solid #563432;
        }

        .d2-1 {
            background-color: #e65e56;
        }

        .d2-2 {
            background-color: #f1b447;
        }

        .d2-3 {
            background-color: #55bd4a;
            /* 实现把第三个盒子放到最右边 */
            margin-left: auto;
        }

        .div3 {
            margin: auto;
            margin-top: 10px;
            background-color: #d7d7d7;
            width: 1280px;
            height: 120px;
            display: flex;
            align-items: center;
        }

        .d3 {
            width: 100px;
            height: 100px;
            border: 2px solid #563432;
        }

        .d3-1 {
            background-color: #e65e56;
        }

        .d3-2 {
            background-color: #f1b447;
        }

        .d3-3 {
            background-color: #55bd4a;
            /* 将3-4两个盒子放到最右边 */
            margin-left: auto;
        }

        .d3-4 {
            background-color: #e65e56;
        }


        .div4 {
            margin: auto;
            margin-top: 10px;
            background-color: #d7d7d7;
            width: 1280px;
            height: 120px;
            display: flex;
            align-items: center;
        }

        .d4 {
            width: 100px;
            height: 100px;
            border: 2px solid #563432;
        }

        .d4-1 {
            background-color: #e65e56;
        }

        .d4-2 {
            background-color: #f1b447;
        }

        .d4-3 {
            background-color: #55bd4a;
            /* 第3个盒子放中间,让第4个盒子放最右边 */
            margin: auto;
        }

        .d4-4 {
            background-color: #e65e56;
        }
    </style>
</head>

<body>
    <!-- 在弹性盒里边使用margin,可以快速的帮我们完成一些想要的布局 -->
    <!-- demo1 -->
    <div class="div1">
        <div class="box1">

        </div>
    </div>

    <!-- demo2 -->
    <div class="div2">
        <div class="d2 d2-1"></div>
        <div class="d2 d2-2"></div>
        <div class="d2 d2-3"></div>
    </div>

    <!-- demo3 -->
    <div class="div3">
        <div class="d3 d3-1"></div>
        <div class="d3 d3-2"></div>
        <div class="d3 d3-3"></div>
        <div class="d3 d3-4"></div>
    </div>

    <!-- demo4 -->
    <div class="div4">
        <div class="d4 d4-1"></div>
        <div class="d4 d4-2"></div>
        <div class="d4 d4-3"></div>
        <div class="d4 d4-4"></div>
    </div>
</body>

</html>